<template>
  <div>
    <div class="foo">
      <div class="foo-img">
        <img :src="this.$store.state.currentPlay.img_url" alt=""/>
      </div>
      <div class="current-play" @click="a()">
        <audio ref="audio" :src="this.$store.state.currentPlay.url"></audio>
        {{ this.$store.state.currentPlay.name }}-{{this.$store.state.currentPlay.singer}}
      </div>
      <div  class="control" @click="musicPlay()">
        <img :src="p_src" alt="">
      </div>
    </div>
    <div class="a" :class="{ active: flag }">
      <div class="header">
        <div class="back" @click="a()"></div>
        <div style="color: #ff7d15; align-self: center; margin-left: 130px">
          歌曲
        </div>
      </div>
      <div class="music-src">
        <img class="img" :src="this.$store.state.currentPlay.img_url" alt="" />
        <h3>{{ this.$store.state.currentPlay.name }}</h3>
        <p style="margin-top:20px;font-size=17px;">
          {{ this.$store.state.currentPlay.singer }}
        </p>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "drawer",
  data() {
    return {
      flag: false,
      p_src:"./imgs/play.png"
    };
  },
  methods: {
    a() {
      if (!this.flag) {
        this.flag = true;
      } else {
        this.flag = false;
      }
    },
    //播放音乐
    musicPlay() {
      if(this.$refs.audio.paused){
        this.p_src="./imgs/Pause.png"
        this.$nextTick(() => {
        this.$refs.audio.play();
      });
      }else{
              this.p_src="./imgs/play.png"
        this.$nextTick(() => {
        this.$refs.audio.pause();
      });
      }
    },
  },
};
</script>
<style scoped>
.current-play {
  align-self: flex-end;
  width: 90%;
  height: 50px;
  line-height: 50px;
  margin-right: 5%;
  border-end-end-radius: 25px;
  border-top-right-radius:25px ;
  font-size: 16px;
  padding-left: 20px;
  color: #f6f6f6;
  margin-bottom:5px ;
  background: #fd9845;
}
.foo{
  margin-left: 10px;
  width: 100%;
  display: flex;
  position: fixed;
  bottom: 50px;
}
.foo-img img{
  border-radius: 5px;
  width: 55px;
  height: 55px;
}
.control{
  position: relative;
  right: 80px;
  top:20px;
}
.a {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 100%;
  background: #f6f6f6;
  transform: translateY(100%);
  transition: transform 0.66s ease-in-out;
  z-index: 99;
}
.a.active {
  transform: translateY(0);
}
.header {
  display: flex;
  margin-top: 10px;
  margin-left: 10px;
}
.back {
  width: 24px;
  height: 24px;
  background: url("./imgs/back.png") no-repeat;
  background-size: cover;
}
.music-src {
  margin: auto 20px;
  margin-top: 30px;
}
.music-src img {
  width: 320px;
  height: 320px;
  border-radius: 10px;
}
</style>